package com.example.movie.mate.controller;

import com.example.movie.mate.pojo.param.HallAddNewParam;
import com.example.movie.mate.pojo.vo.HallVO;
import com.example.movie.mate.service.IHallService;
import com.example.movie.mate.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 影厅控制器
 */
@Tag(name = "3. 影厅管理模块")
@RestController
@RequestMapping("/api/hall")
public class HallController {

    @Autowired
    private IHallService hallService;

    @ApiOperationSupport(order = 100)
    @Operation(summary = "[管理] 新增影厅")
    @PostMapping("/manage/add-new")
    public JsonResult<Void> addNew(@ParameterObject @Valid HallAddNewParam param) {
        hallService.addNew(param);
        return JsonResult.ok();
    }

    @ApiOperationSupport(order = 410)
    @Operation(summary = "[游客] 根据ID查询影厅信息")
    @Parameter(name = "id", description = "影厅id", required = true, example = "1")
    @GetMapping("/public/{id}")
    public JsonResult<HallVO> selectById(@PathVariable Long id) {
        HallVO data = hallService.selectById(id);
        return JsonResult.ok(data);
    }

    @ApiOperationSupport(order = 420)
    @Operation(summary = "[游客] 查询所有影厅列表")
    @GetMapping("/public")
    public JsonResult<List<HallVO>> selectAll() {
        List<HallVO> list = hallService.selectAll();
        return JsonResult.ok(list);
    }
}